﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace bianji
{
    public partial class Form_main : Form
    {
        public string src;

        public Form_main()
        {
            InitializeComponent();
        }

        private void Form_main_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(src))
            {
                //StreamReader sr = new StreamReader(src, Encoding.Default);
                //this.richTextBox1.Text = sr.ReadToEnd();
                //sr.Close();

                this.textBox_url.Text = src;
                Uri uri = new Uri(src);
                this.webBrowser1.Url = uri;


                this.richTextBox1.Text = this.webBrowser1.DocumentText;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void 刷新ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            shuaxin();
        }

        private void shuaxin()
        {
            string struri = this.textBox_url.Text;
            if (struri.Trim() == "") { return; }

            Uri uri = new Uri(struri);
            this.webBrowser1.Url = uri;

            this.richTextBox1.Text = this.webBrowser1.DocumentText;
        }

        //private void Form_main_KeyDown(object sender, KeyEventArgs e)
        //{
        //    if (e.KeyCode == Keys.F5)
        //    {
        //        shuaxin();
        //    }
        //}

        //private void Form_main_KeyUp(object sender, KeyEventArgs e)
        //{
        //    if (e.KeyCode == Keys.F5)
        //    {
        //        shuaxin();
        //    }
        //}

        private void tabControl1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.F5)
            {
                shuaxin();
            }
        }

      
    }
}
